package com.neu.service;

import com.alibaba.druid.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.neu.dao.ShoppingCouponMapper;
import com.neu.dao.ShoppingCouponUserMapper;
import com.neu.domain.*;
import com.neu.domain.ShoppingCoupon.Column;
import com.neu.util.CouponConstant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

@Service
public class ShoppingCouponService {
    @Resource
    private ShoppingCouponMapper couponMapper;
    @Resource
    private ShoppingCouponUserMapper couponUserMapper;

    private Column[] result = new Column[]{Column.id, Column.name, Column.desc, Column.tag,
                                            Column.days, Column.startTime, Column.endTime,
                                            Column.discount, Column.min};

	

    /**
     * 查询，空参数
     *
     * @param offset
     * @param limit
     * @param sort
     * @param order
     * @return
     */
	//分页查询
	public List<ShoppingCoupon> querySelective(){
		ShoppingCouponExample example=new ShoppingCouponExample();
		
		return couponMapper.selectByExample(example);
	}
	//获取优惠券领取用户信息
	public List<ShoppingCouponUser> queryList(){
		ShoppingCouponUserExample example=new ShoppingCouponUserExample();
		return couponUserMapper.selectByExample(example);
	}
	//获取优惠券详情信息
	public ShoppingCoupon findById(Integer id) {
		
		return couponMapper.selectByPrimaryKey(id);
	}
	//添加
	public void add(ShoppingCoupon coupon){
		
		couponMapper.insertSelective(coupon);
	}
	//添加
	public int updateById(ShoppingCoupon coupon) {
		
		return couponMapper.updateByPrimaryKeySelective(coupon);
	}
	//删除
	public void deleteById(int id) {
		couponMapper.logicalDeleteByPrimaryKey(id);
	}

	public List<ShoppingCoupon> queryRegister() {
		return null;
	}

	/**
     * 查询
     *
     * @param criteria 可扩展的条件
     * @param offset
     * @param limit
     * @param sort
     * @param order
     * @return
     */
//  TODO 


        // 过滤掉登录账号已经领取过的coupon
//  TODO 

//  TODO 

//  TODO 


//  TODO 

    /**
     * 查询新用户注册优惠券
     *
     * @return
     */
//  TODO 

//  TODO 



    /**
     * 生成优惠码
     *
     * @return 可使用优惠码
     */
//  TODO 

    /**
     * 查询过期的优惠券:
     * 注意：如果timeType=0, 即基于领取时间有效期的优惠券，则优惠券不会过期
     *
     * @return
     */
//  TODO 
}
